package com.wmyg.antifake.entity;

import lombok.Data;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;

/**
 * @author 王卓逸
 * @program TODO
 * @description TODO
 * @create 2019-05-05
 */
@Entity
@EntityListeners(AuditingEntityListener.class)
@Data
@Table(name = "bk_user_address")
public class UserAddress {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "address_id")
    private Integer addressId;

//    @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.REFRESH}, fetch = FetchType.EAGER)
//    @NotFound(action = NotFoundAction.IGNORE)
//    @JoinColumn(name = "area_id")
//    private Area area;

    @Column(name = "area")
    private String area;

    @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.REFRESH}, fetch = FetchType.EAGER)
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "user_id")
    private BkUser user;

    @Column(name = "detail")
    private String detail;

    @Column(name = "addressee")
    private String addressee;

    @Column(name = "phone")
    private String phone;

    @Column(name = "state")
    private Integer state = 1; //0.不显示， 1.显示

    @CreatedDate
    @Column(name = "create_time")
    private Date createTime;

    @LastModifiedDate
    @Column(name = "modify_time")
    private Date modifyTime;

}
